<!-- 在这个文件对每个tab对应的列表进行渲染 -->
<template>
	<view class="paryorder-content">
		<z-paging ref="paging" v-model="dataList" @query="queryList" hide-empty-view	 :fixed="false" :auto="true">
			<template #top>
				<view class="" style="background-color: #F8F8F8;">
					<u-navbar :border-bottom="false" title="订单详情" :background="{'background':'#F8F8F8'}" :title-size="36" :title-bold="true" :title-color="textColor">
					</u-navbar>
				</view>
			</template>
			
			<view class="">
				<view class="section-list">
					<view class="section-item">
						<text class="u-font-32" style="font-weight: bold;">交易详情</text>
						<view class="u-flex u-row-between u-m-t-30">
							<view class="u-flex u-m-b-10">
								<view :class="['u-flex', 'u-row-center','u-m-r-20', 'u-col-center','pay-status',{'pay-status-active':orderInfo.tradeState>0}]">
									<u-icon name="order" class="u-m-r-10 u-m-b-4" :color="orderInfo.tradeState>0?'#FFBB1A':'#999'" size="30"></u-icon>
									<text class="u-font-22" :style="{'color':orderInfo.tradeState>0?'#FFBB1A':'#999'}"> {{orderInfo.tradeStateName}}</text>
								</view> 
								<view :class="['u-flex', 'u-row-center','u-m-r-20', 'u-col-center','pay-status',{'pay-status-active':orderInfo.paymentState!==0}]">
									<img :src="orderInfo.paymentState!==0?'static/xiaoshou/zhifudan.png':'static/xiaoshou/zhifuda.png'" style="width: 26rpx;height: 26rpx;" alt="">
									<text class="u-font-22 u-m-l-10" :style="{'color':orderInfo.paymentState!==0?'#FFBB1A':'#999'}"> {{orderInfo.paymentStateName}}</text>
								</view>
							</view>
						</view>
						<view class="u-flex u-m-t-18">
							<view class="shop-mark">销</view>
							<view class="u-font-28 u-m-l-20">{{orderInfo.sellerName}}</view>
						</view>
						<view class="u-flex u-m-t-10 u-m-b-18">
							<view class="shop-mark" style="background-color: #FF551A;">采</view>
							<view class="u-font-28 u-m-l-20">{{orderInfo.buyerName}}</view>
						</view>
						<view class="u-flex u-row-between">
							<view class="section-item-count u-m-b-10 u-flex u-col-center" >
								下单时间<text class="u-m-l-20 u-font-22" style="color: #999;">  {{$u.timeFormat(orderInfo.createdTime, 'yyyy-mm-dd hh:MM')}}  </text>
							</view>
						</view>
					</view>
				</view>
				<view class="box-color box-padding u-m-b-20">
					<view class=" u-m-b-30">
						<text class="u-font-32" style="font-weight: bold;">商品明细</text>
					</view>
					<view v-if="orderInfo.orders.length === 0" class="u-text-center u-p-35">
						暂无数据
					</view>
					<view v-for="(item,index) in orderInfo.orders" @click="$mRouter.push({ route: '/pages/index/xiangqing?id=' + item.itemId })" style="position: relative;" :key="index" class="item u-flex u-m-b-20">
						<image :src="item.url" style="width: 180rpx;height: 180rpx;border-radius: 10rpx;" mode=""></image>
						<image src="/static/order/giftMark.png" style="width: 90rpx;height: 90rpx;border-radius: 10rpx;position: absolute;bottom: 0;left: 0;" v-if="item.isGift" mode=""></image>
						<view class="u-flex-col u-row-around u-flex-1 u-m-l-20" style="height: 180rpx">
							<view class="u-flex u-row-between">
								<text class="u-font-28" style="height: 40rpx;overflow-y: hidden;">{{ item.itemName }}</text>
								<text class="u-font-32">￥{{ item.price }}</text>
							</view>
							<view class="u-flex u-row-between">
								<view class="grey-box">
									{{ item.specification }}
								</view>
								<view class="grey-box" style="margin-right: 0;">
									x{{ item.quantity }}
								</view>
							</view>
						</view>
					</view>
					<view class="u-border-bottom"></view>
					<view class="u-flex u-row-between u-p-t-30  u-p-b-14">
						<text class="u-font-32 text-bold">实付款</text>
						<text :style="{fontSize: '40rpx', color: badgeColor}">￥{{ orderInfo.totalAmount }}</text>
					</view>
				</view>
				
				
				
			</view>
		</z-paging>
	</view>
</template>

<script>
	import { useShopStore } from '@/store/shop.js';
	import { mapState } from 'pinia';
	export default {
		data() {
			return {
				//v-model绑定的这个变量不要在分页请求结束中自己赋值！！！
				dataList: [],
				searchText:'',
				tradeId:'',
				orderInfo:{
					orders:[]
				},
				info:{}
			}
		},
		onLoad(options) {
			this.tradeId = options.id;
		},
		computed:{
			...mapState(useShopStore, {storeShop: 'shop'})
		},
		methods: {
			reloadFn(){
				this.$refs.paging.reload();
			},
		
			async queryList(pageNo, pageSize) {
				//组件加载时会自动触发此方法，因此默认页面加载时会自动触发，无需手动调用
				//这里的pageNo和pageSize会自动计算好，直接传给服务器即可
				//模拟请求服务器获取分页数据，请替换成自己的网络请求
				const params = {
					pageIndex: pageNo,
					pageSize: pageSize,
					shopId:this.storeShop.id,
					tradeId:this.tradeId,
				}
				uni.showLoading({
					title: '加载中...',
					mask: false
				});
				const res = await this.$newHttp.get('api/BrandOwnerSalesman/GetMyCustomerTradesDetail', {params:params} );
				uni.hideLoading({
					title: '加载中...'
				})
				if(res.code === 200){
					this.orderInfo = res.data;
					this.$refs.paging.complete();
				}else{
					this.$refs.paging.complete(false);
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	/* 注意:父节点需要固定高度，z-paging的height:100%才会生效 */
	.paryorder-content {
		height: 100%;
		.section-list{
			background-color: #fff;
			padding: 35rpx;
			margin-bottom: 20rpx;
			.shop-mark{
				color: #fff;background-color: #FFBB1A;border-radius: 10rpx;width: 36rpx;height: 36rpx;
				text-align: center;
				font-size: 22rpx;
				line-height: 36rpx;
			}
			.section-item{
				width: 100%;
				.pay-status{
					border:1px solid #999;
					box-sizing: border-box;
					padding: 8rpx 18rpx 8rpx 10rpx;
					border-radius: 30rpx;
					color: #999;
				}
				.pay-status-active{
					border-color: #FFBB1A !important;
					color: #FFBB1A;
				}
				.section-item-count{
					font-size: 24rpx;
					color: #999;
				}
			}
		}
	}
</style>
